module lang.d.sts.expressions.dassociativearrayliteral;

import lang.d.sts.expressions.dexpression;
import lang.d.types.dtype;
import lang.d.visitors.dvisitor;

class DAssociativeArrayLiteral: DExpression {
    public DExpression[DExpression] myKeyValuePairs;

    // TODO: is key already in myKeyValuePairs
    public void addKeyValuePair(DExpression key, DExpression value) {
        myKeyValuePairs[key] = value;
        key.setParent(this);
        value.setParent(this);
    }

    public DExpression[DExpression] getKeyValuePairs() {
        return myKeyValuePairs;
    }

    public DExpression[] getKeys() {
        return myKeyValuePairs.keys;
    }

    public DExpression opIndex(DExpression key) {
        return myKeyValuePairs[key];
    }

    override public void accept(DVisitor visitor) {
        visitor.visitAssociativeArrayLiteral(this);
    }
}

